#include "scheduler.h"

typedef struct
{
	void (*task_func)(void);
	uint32_t rate_time;
	uint32_t run_time;
}task_t;

static task_t task_scheduler[]={
	{led_proc,1,0},
	{lcd_proc,200,0},
	{key_proc,10,0},
	{adc_proc,50,0},
	{input_ic_proc,50,0},
	{five_second,1,0},
	{pwm_change_proc,249,0},
	{led_shan_proc,200,0},
	{panduan_max_proc,1,0}
};

uint8_t task_num;

void scheduler_init(void)
{
	task_num = sizeof(task_scheduler)/sizeof(task_t);
}

void scheduler_run(void)
{
	for(uint8_t i = 0;i<task_num ; i++)
	{
		uint32_t Now_time = HAL_GetTick();
		if(Now_time >= task_scheduler[i].rate_time + task_scheduler[i].run_time)
		{
			task_scheduler[i].run_time = Now_time;
			task_scheduler[i].task_func();
		}
	}
}
